﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.IO;

public partial class Content_View_User_TraTu : System.Web.UI.Page
{
    CTloaitu ct = new CTloaitu();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            string type = Request.QueryString["type"];
            string key = Request.QueryString["key"];
            if (type != null && key != null)
            {
                DataList dtl = new DataList();
                switch (type)
                {
                    case "VE":
                        MultiView1.SetActiveView(View1);
                        dtl = this.dtAnh;
                        break;
                    case "EV":
                        MultiView1.SetActiveView(View2);
                        dtl = this.dtViet;
                        break;

                }
                DataTable dt = new DataTable();
                dt = ct.Load_ngonngu(type, key);
                dtl.DataSource = dt;
                dtl.DataBind();
            }

            string filename = Server.MapPath("~/Content/Content/" + tentt.Text + ".doc");
            if (!File.Exists(filename))
            {
                return;
            }
            FileStream fs = new FileStream(filename, FileMode.Open);
            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                string noidung = (string)formatter.Deserialize(fs);
                this.dtAnh = noidung;
            }
            catch (Exception)
            {
                FCKeditor1.Value = "tập tin đã bị chuyển nội dung!!!";
            }
            fs.Close();
        }
    }
}